<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="title">
            <h:outputText value="List all Public Holidays"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <h:form>
                <p:panel id="publicHolidays" header="List all Public Holidays">
                    <h:form>
                        <p:dataTable value="#{calendarEntityController.items}" 
                                     var="item" style="table-layout:fixed"
                                     paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15">

                            <p:column filterBy="#{item.event}">
                                <f:facet name="header">
                                    <h:outputText value="Event"/>
                                </f:facet>
                                <h:outputText value="#{item.event}"/>
                            </p:column>

                            <p:column filterBy="#{item.day}">
                                <f:facet name="header">
                                    <h:outputText value="Date"/>
                                </f:facet>
                                <h:outputText value="#{item.day}"/>
                            </p:column>

                            <p:column filterBy="#{item.month}">
                                <f:facet name="header">
                                    <h:outputText value="Month"/>
                                </f:facet>
                                <h:outputText value="#{item.month}"/>
                            </p:column>

                            <p:column filterBy="#{item.year}">
                                <f:facet name="header">
                                    <h:outputText value="Year"/>
                                </f:facet>
                                <h:outputText value="#{item.year}"/>
                            </p:column>

                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="&nbsp;"/>
                                </f:facet>
                                <p:commandButton image="ui-icon ui-icon-trash" action="#{calendarEntityController.destroy}" ajax="false"/>
                            </p:column>
                        </p:dataTable> 
                    </h:form>
                </p:panel>
                <p:commandButton action="#{calendarEntityController.prepareCreate}" onclick="holiday.show();" type="button" value="Add Public Holiday" ajax="false"/>
                <p:dialog header="Add Public Holiday" widgetVar="holiday" modal="true" height="360" width="280" > 
                    <h:outputText value="Event: "/>
                    <p:inputText value="#{calendarEntityController.event}"> 
                        <p:ajax event="keyup"/>
                    </p:inputText>
                    <br />
                    <br />
                    <p:calendar value="#{calendarEntityController.publicHoliday}" mode="inline"   
                                onSelectUpdate="@form:publicHolidays"   
                                selectListener="#{calendarEntityController.handleDateSelect}"/>
                    <br />
                    <p:commandButton oncomplete="holiday.hide()" value="Finish"/>
                </p:dialog>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
